Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix panic in 'azurerm_api_management_operation' #5243

Closed
wants to merge 166 commits into from

Conversation

jackbatzner
Copy link
Contributor

@jackbatzner jackbatzner commented Dec 23, 2019

Fix a panic I was experiencing when the 'description' property was not able to be mapped

2019-12-23T20:55:50.9046888Z panic: interface conversion: interface {} is nil, not map[string]interface {}
2019-12-23T20:55:50.9047936Z 2019-12-23T20:55:50.658Z [DEBUG] plugin.terraform-provider-azurerm_v1.37.0_x4.exe: 
2019-12-23T20:55:50.9048202Z 2019-12-23T20:55:50.658Z [DEBUG] plugin.terraform-provider-azurerm_v1.37.0_x4.exe: goroutine 1305 [running]:
2019-12-23T20:55:50.9048510Z 2019-12-23T20:55:50.658Z [DEBUG] plugin.terraform-provider-azurerm_v1.37.0_x4.exe: github.com/terraform-providers/terraform-provider-azurerm/azurerm.expandApiManagementOperationRequestContract(0xc00114f3f0, 0x1, 0x1, 0x35d37a0, 0xc000fe10e0, 0x3d80301)
2019-12-23T20:55:50.9048828Z 2019-12-23T20:55:50.658Z [DEBUG] plugin.terraform-provider-azurerm_v1.37.0_x4.exe: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/azurerm/resource_arm_api_management_api_operation.go:251 +0x3cf
2019-12-23T20:55:50.9049615Z 2019-12-23T20:55:50.658Z [DEBUG] plugin.terraform-provider-azurerm_v1.37.0_x4.exe: github.com/terraform-providers/terraform-provider-azurerm/azurerm.resourceArmApiManagementApiOperationCreateUpdate(0xc0001de000, 0x3569860, 0xc0009cc000, 0x0, 0x0)
2019-12-23T20:55:50.9049993Z 2019-12-23T20:55:50.658Z [DEBUG] plugin.terraform-provider-azurerm_v1.37.0_x4.exe: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/azurerm/resource_arm_api_management_api_operation.go:125 +0x3ed
2019-12-23T20:55:50.9050429Z 2019-12-23T20:55:50.658Z [DEBUG] plugin.terraform-provider-azurerm_v1.37.0_x4.exe: github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Resource).Apply(0xc000446180, 0xc0011b7090, 0xc000fe01c0, 0x3569860, 0xc0009cc000, 0xc000d35b01, 0xc000fd0f58, 0x36d86e0)
2019-12-23T20:55:50.9050840Z 2019-12-23T20:55:50.658Z [DEBUG] plugin.terraform-provider-azurerm_v1.37.0_x4.exe: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform-plugin-sdk/helper/schema/resource.go:305 +0x3bb
2019-12-23T20:55:50.9051233Z 2019-12-23T20:55:50.658Z [DEBUG] plugin.terraform-provider-azurerm_v1.37.0_x4.exe: github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Provider).Apply(0xc0008d4f00, 0xc000bd5a68, 0xc0011b7090, 0xc000fe01c0, 0xc000997a68, 0xc00097b2f0, 0x36da7e0)
2019-12-23T20:55:50.9051854Z 2019-12-23T20:55:50.658Z [DEBUG] plugin.terraform-provider-azurerm_v1.37.0_x4.exe: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform-plugin-sdk/helper/schema/provider.go:294 +0x196
2019-12-23T20:55:50.9052271Z 2019-12-23T20:55:50.658Z [DEBUG] plugin.terraform-provider-azurerm_v1.37.0_x4.exe: github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin.(*GRPCProviderServer).ApplyResourceChange(0xc0000b2c18, 0x438a480, 0xc000d84f30, 0xc000924420, 0xc0000b2c18, 0xc000d84f30, 0xc000c4dbd0)
2019-12-23T20:55:50.9053111Z 2019-12-23T20:55:50.658Z [DEBUG] plugin.terraform-provider-azurerm_v1.37.0_x4.exe: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin/grpc_provider.go:885 +0x88b
2019-12-23T20:55:50.9053482Z 2019-12-23T20:55:50.658Z [DEBUG] plugin.terraform-provider-azurerm_v1.37.0_x4.exe: github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5._Provider_ApplyResourceChange_Handler(0x3a43d40, 0xc0000b2c18, 0x438a480, 0xc000d84f30, 0xc0009243c0, 0x0, 0x438a480, 0xc000d84f30, 0xc000244000, 0x2d5)
2019-12-23T20:55:50.9053836Z 2019-12-23T20:55:50.658Z [DEBUG] plugin.terraform-provider-azurerm_v1.37.0_x4.exe: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5/tfplugin5.pb.go:3189 +0x245
2019-12-23T20:55:50.9054159Z 2019-12-23T20:55:50.658Z [DEBUG] plugin.terraform-provider-azurerm_v1.37.0_x4.exe: github.com/terraform-providers/terraform-provider-azurerm/vendor/google.golang.org/grpc.(*Server).processUnaryRPC(0xc0000d22c0, 0x43ddc00, 0xc000061200, 0xc0013acb00, 0xc0008d7a10, 0x7d74560, 0x0, 0x0, 0x0)
2019-12-23T20:55:50.9054574Z 2019-12-23T20:55:50.658Z [DEBUG] plugin.terraform-provider-azurerm_v1.37.0_x4.exe: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/google.golang.org/grpc/server.go:995 +0x46d
2019-12-23T20:55:50.9055085Z 2019-12-23T20:55:50.658Z [DEBUG] plugin.terraform-provider-azurerm_v1.37.0_x4.exe: github.com/terraform-providers/terraform-provider-azurerm/vendor/google.golang.org/grpc.(*Server).handleStream(0xc0000d22c0, 0x43ddc00, 0xc000061200, 0xc0013acb00, 0x0)
2019-12-23T20:55:50.9055398Z 2019-12-23T20:55:50.658Z [DEBUG] plugin.terraform-provider-azurerm_v1.37.0_x4.exe: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/google.golang.org/grpc/server.go:1275 +0xdad
2019-12-23T20:55:50.9055707Z 2019-12-23T20:55:50.658Z [DEBUG] plugin.terraform-provider-azurerm_v1.37.0_x4.exe: github.com/terraform-providers/terraform-provider-azurerm/vendor/google.golang.org/grpc.(*Server).serveStreams.func1.1(0xc0006dc110, 0xc0000d22c0, 0x43ddc00, 0xc000061200, 0xc0013acb00)
2019-12-23T20:55:50.9056022Z 2019-12-23T20:55:50.658Z [DEBUG] plugin.terraform-provider-azurerm_v1.37.0_x4.exe: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/google.golang.org/grpc/server.go:710 +0xa6
2019-12-23T20:55:50.9056319Z 2019-12-23T20:55:50.658Z [DEBUG] plugin.terraform-provider-azurerm_v1.37.0_x4.exe: created by github.com/terraform-providers/terraform-provider-azurerm/vendor/google.golang.org/grpc.(*Server).serveStreams.func1
2019-12-23T20:55:50.9056589Z 2019-12-23T20:55:50.658Z [DEBUG] plugin.terraform-provider-azurerm_v1.37.0_x4.exe: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/google.golang.org/grpc/server.go:708 +0xa8

@ghost ghost added the size/XS label Dec 23, 2019
Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Brunhil,

thank you for the fix, however we typically don't error when things are missing and instead just ignore the property. Once that change is made this should be good to merge

@@ -250,15 +250,27 @@ func expandApiManagementOperationRequestContract(input []interface{}) (*apimanag
}

vs := input[0].(map[string]interface{})
if vs == nil {
return nil, fmt.Errorf("Error mapping input")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We typically just ignore errors like this

Suggested change
return nil, fmt.Errorf("Error mapping input")
return nil, nil

Comment on lines 259 to 262
if headersRaw == nil {
return nil, fmt.Errorf("Error mapping `header`")
}
headers := azure.ExpandApiManagementOperationParameterContract(headersRaw)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So instead could we conditionally assign this here upon missing headers instead of an error?

@ghost ghost added size/XXL and removed size/XS labels Dec 30, 2019
katbyte pushed a commit that referenced this pull request Dec 30, 2019
Fix panic in 'azurerm_api_management_operation'

Recreatd #5243 after the changes to the provider organization.
jackbatzner pushed a commit to jackbatzner/terraform-provider-azurerm that referenced this pull request Dec 31, 2019
Fix panic in 'azurerm_api_management_operation'

Recreatd hashicorp#5243 after the changes to the provider organization.
@ghost
Copy link

ghost commented Jan 8, 2020

This has been released in version 1.40.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:

provider "azurerm" {
    version = "~> 1.40.0"
}
# ... other configuration ...

@ghost ghost removed the waiting-response label Jan 8, 2020
@jackbatzner jackbatzner deleted the fix_apim_op_panic branch March 14, 2020 14:48
@ghost
Copy link

ghost commented Mar 14, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks!

@ghost ghost locked and limited conversation to collaborators Mar 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants